<?
include('class.php');

class moje extends JSRPC{

 function pokus($a,$b){
  //$this->response->alert($a.'+'.$b.'='.($a+$b));
  //$this->response->getElementById('label')->innerHTML='ahoj';
  $this->getElementById('label')->innerHTML='ahoj';
  $this->style('label')->backgroundColor='#ff8040';
  $this->style('label')->fontWeight='bold';
 }
 function rozdil($a,$b){
  $this->alert($a.'-'.$b.'='.($a-$b));
 }
 function soucet($a,$b){
   return $a+$b;
  return "Soucet '$a + $b' = ".($a+$b);
 }

 function opakuj($retezec,$pocet){
  $s='';
  for($i=0;$i<$pocet;$i++){$s.=$retezec;}
  $this->getElementById('label')->innerHTML=$s;
 }
 
 function json(){
 $arr=array('leva','prava','seno','slama','kostka','cukru','silu','dava');
 
 self::log(serialize($this));
 
 return $arr;
}

 function arr($a){
 $ar=json_decode($a);
 return $ar[1];
 return 'ahoj';
 }

}

$rpc=new moje();
//$rpc->debug(1);
$rpc->registerMethod('pokus','a,b');
$rpc->registerMethod('rozdil','a,b');
$rpc->registerMethod('opakuj','retezec, pocet');

$rpc->registerFunction('soucet','a,b');
$rpc->registerJSONFunction('json','');
$rpc->registerFunction('arr','a[]');

$rpc->run();

?>